// Number_Crop_1.c ( 21 )
// This programme accepts two numerical ( whole decimal ) arguments . It outputs the second number in a number of digits specified by the first argument , cropping from the left or adding zeroes to the left as necessary .
#include <stdio.h>
#include <stdlib.h>
int main( int argc , char** argv ) {
  int State1 ;
  int Count1 ;
  int Error1 ;
  State1 = 0 ;
  Count1 = 0 ;
  if ( argc == 3 ) {
    State1 = 1 ;
    Error1 = 0 ;
    while ( ( *( *( argv + 1 ) + Count1 ) > 0 ) && ( Count1 < 32 ) && ( Error1 == 0 ) ) {
      Error1 = 1 ;
      if ( ( *( *( argv + 1 ) + Count1 ) >= 48 ) && ( *( *( argv + 1 ) + Count1 ) <= 58 ) ) {
        Error1 = 0 ;
      }
      Count1 ++ ;
    }
    if ( ( Error1 == 0 ) && ( Count1 > 0 ) ) {
      Count1 = 0 ;
      while ( ( *( *( argv + 2 ) + Count1 ) > 0 ) && ( Count1 < 32 ) && ( Error1 == 0 ) ) {
        Error1 = 1 ;
        if ( ( *( *( argv + 2 ) + Count1 ) >= 48 ) && ( *( *( argv + 2 ) + Count1 ) <= 58 ) ) {
          Error1 = 0 ;
        }
        Count1 ++ ;
      }
      if ( ( Error1 == 0 ) && ( Count1 > 0 ) ) {
        int Length1 ;
        int Length2 = Count1 ;
        int Count2 = 0 ;
        sscanf( *( argv + 1 ) , "%d" , &Length1 ) ;
        char* Output1 = malloc( Length1 + 1 ) ;
        if ( Output1 == NULL ) {
          fprintf( stderr , "Either there are memory problems or something has gone horribly wrong .\n" ) ;
          return 1 ;
        }
        Count1 = 0 ;
        while ( Count1 < Length1 ) {
          Output1[ Count1 ] = '0' ;
          Count1 ++ ;
        }
        Output1[ Count1 ] = ( char )0 ;
        while ( Count2 < Length2 ) {
          Output1[ Length1 - Count2 - 1 ] = *( *( argv + 2 ) + Length2 - Count2 - 1 ) ;
          Count2 ++ ;
        }
        printf( "%s" , Output1 ) ;
        free( Output1 ) ;
      } else {
        fprintf( stderr , "Either the value value was too short or contained characters other than decimal digits .\n" ) ;
      }
    } else {
      fprintf( stderr , "Either the length value was too short or contained characters other than decimal digits .\n" ) ;
    }
  } else {
    Error1 = 1 ;
  }
  if ( ( Error1 > 0 ) || ( argc == 2 ) ) {
    if ( ( strcmp( argv[ 1 ] , "--Help" ) == 0 ) || ( strcmp( argv[ 1 ] , "--help" ) == 0 ) ) {
      fprintf( stderr , "Number_Crop_1.c ( 21 )\n" ) ;
      fprintf( stderr , "This programme accepts two numerical ( whole decimal ) arguments . It outputs the second number in a number of digits specified by the first argument , cropping from the left or adding zeroes to the left as necessary .\n" ) ;
    } else {
      fprintf( stderr , "The input is invalid .\n" ) ;
    }
  }
}

